﻿using Blog.Core.Model.Model;
using Microsoft.EntityFrameworkCore;

namespace Blog.Core.Data
{
    public class BlogContext : DbContext
    {
        public BlogContext(DbContextOptions<BlogContext> options) : base(options)
        {
        }
        public DbSet<Advertisement> Advertisements { get; set; }

        public DbSet<Course> Courses { get; set; }
        public DbSet<Enrollment> Enrollments { get; set; }
        public DbSet<Student> Students { get; set; }
        public DbSet<Person> People { get; set; }
        public DbSet<Instructor> Instructors { get; set; }
        public DbSet<Pupil> Pupils { get; set; }
        public DbSet<User> Users { get; set; }
        public DbSet<MainMenu> MainMenus { get; set; }
        public DbSet<MenuBase> MenuBases { get; set; }
        public DbSet<SubMenu> SubMenus { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<UserRole> UserRoles { get; set; }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //modelBuilder.Entity<Advertisement>().ToTable("Advertisement");
            //modelBuilder.Entity<Course>().ToTable("Course");
            //modelBuilder.Entity<Enrollment>().ToTable("Enrollment");
            //modelBuilder.Entity<Instructor>().ToTable("Instructor");
            //modelBuilder.Entity<Student>().ToTable("Student");
            //modelBuilder.Entity<Person>().ToTable("People");
            //modelBuilder.Entity<User>().HasIndex(c=>c.UserName).IsUnique();
            modelBuilder.Entity<UserRole>().HasKey(c=> new{ c.RoleID,c.UserID});
        }
        public DbSet<Blog.Core.Model.ViewModel.StudentDTO> StudentDTO { get; set; }
    }
}
